perm filename JUST[E,ALS]1 blob
sn#165942 filedate 1975-07-01 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 GETC,JTAB,JDSPN,JDSPS,JDSPP
C00009 ENDMK
Cā;
GETC,JTAB,JDSPN,JDSPS,JDSPP
DEFINE GETC
{ILDB C,A
SKIPE JTAB(C)
XCT @JTAB(C)}
;Dispatch table for justify.
JTAB: (DSP) ;0 NUL
REPEAT 10,<0> ;001-011 Treat as standard characters
4(DSP) ;011 TAB
3(DSP) ;012 LF
0 ;013 VT (INTEGRAL)
5(DSP) ;014 FF
2(DSP) ;015 CR
REPEAT 22,<0> ;016-037 Treat as standard characters
7(DSP) ;040 SP
10(DSP) ;041 !
REPEAT 14<,<0> ;042-055 Treat as standard characters
10(DSP) ;056 .
REPEAT 20,<0> ;057-076 Treat as standard characters
10(DSP) ;077 ?
REPEAT 75,<0> ;100-174 Treat as standard characters
6(DSP) ;175 ALT-MODE
0 ;176 }
1(DSP) ;177 RUBOUT
;Dispatch table used after a normal character
JDSPN: JRST N3 ;NUL 0
JRST N0 ;BS 1
JRST C1 ;CR 2
JRST L1A ;LF 3
JRST T1 ;TAB 4
JRST N3 ;FF 5
JRST N3 ;ALT MODE 6
JRST P1 ; . ! ? 7
JRST S1 ;SP 10
;Dispatch table used after . ? ! to identify punctuation use
JDSPP: JRST P3 ;NUL 0
JRST P3 ;BS 1
JRST C1 ;CR 2
JRST L1A ;LF 3
JRST T1A ;TAB 4
JRST P3 ;FF 5
JRST P3 ;ALT MODE 6
JRST P1 ; . ! ? 7
JRST S1A ;SP 10
Dispatch table used after a SP, TB or CR to eat extra spaces
JDSPS: JRST S6 ;NUL 0
JRST S6 ;BS 1
JRST C1 ;CR 2
JRST L1 ;LF 3
JRST S6 ;TAB 4
JRST N3 ;FF 5
JRST N3 ;ALT MODE 6
JRST P1 ; . ! ? 7
JRST S6 ;SP 10
Dispatch table used after NXTLIN to detect paragraph signal
JDSPC: JRST S6 ;NUL 0
JRST S6 ;BS 1
JRST C1 ;CR 2
JRST L1 ;LF 3
JRST S6 ;TAB 4
JRST N3 ;FF 5
JRST N3 ;ALT MODE 6
JRST P1 ; . ! ? 7
JRST S5 ;SP 10
;B is set so that it turns positive if the last character read is one too many.
;A has been saved at last word break so this character is always reread.
;CR's are treated as SP's and the LF is used to signal line end
N0: ADD D,[70000,,0] ;To accept BS symbols
SUB B,[1,,1]
JRST N3
;Normal character loop
N1: MOVEI DSP,JDSPN ;Set up to dispatch
N2: IDPB C,D ;Store the last read character
N3: GETC ;Macro to get next character
N4; AOBJN B,N2 ;Loop
;We have enough characters for a new line
N5: SKIPN JWCOL ;Has a word break been found?
JRST N8 ;No, so keep going
MOVE A,ASAVE ;Back up to the last word break
MOVE D,DSAVE
N6: MOVEI C,0
IDPB C,D ;Overwrite the word terminating space
PUSHJ P,JDUMP
MOVE D,[440700,,BUF]
SETZM BUF ;Safety precaution
JRST S5 ;Start out by eating all spaces, just to be sure
;We haven't met a word break on this line
N8: HRRZS B
CAIGE B,=119 ;Limit of 120 characters willy-nilly
JRST N2 ;Keep going
IDPB C,D ;Save the last character
MOVEM A,ASAVE
MOVEM D,DSAVE
HRRZM B,JWCOL
JRST N6 ;Stop
;TAB and SP eating loop
T1: MOVEI C,40 ;Tabs are compressed to spaces
S1 MOVEM D,DSAVE ;We may have to replace the space with a NUL
S2: HRRZM B,JWCOL ;The word count for us in JUST
S3: IDPB C,D
S4: MOVEM A,ASAVE ;Used if next word does not fit
S5: MOVEI DSP,JDSPS ;Set dispatch to throw out extra spaces
S6: GETC
AOBJN B,N1 ;The start of another word
JRST N5 ;Woops, it will not go
;Double space after punctuation with . ! ?
T1A: MOVEI C,40 ;TABs are all compressed to spaces
S1A: MOVEM D,DSAVE ;We may have to stop here
MOVEM A,ASAVE ;We may need to reread the next character
HRRZM B,JWCOL
AOBJP B,.+1
AOBJP B,N6 ;Is there room for 2 spaces?
IDPB C,D
IDPB C,D ;Put them in
JRST S5 ;Eat any more
;Punctuation testing code
P1: IDPB C.D
P2: MOVEI DSP,JPDSP ;Special dispatch needed to put 2 spaces after
P3: GETC
P4: AOBJN B,N1 ;Not punctuation since normal character follows
P5: JRST N5 ;Woops, no space for the next character
;Special case of a LF without a CR
L1A: ADD A,[70000,,0] ;Pretend there was a CR
SKIPG A
SUB A,[340000,,1]
;A CR calls for a SP if more text goes on the line
C1: MOVEM A,ASAVE
MOVEM D,DSAVE
HRRZM B,JWCOL
MOVEI C,40
IDPB C,D
C2: AOBJN B,N5
C3: PUSHJ P,NXTLIN ;Get a new input line
MOVEI DSP,JDSPC ;To test for paragraph signal
GETC
JRST N1 ;Anormal character so no new paragraph